/** index.js By Beginner Emain:zheng_jinfan@126.com HomePage:http://www.zhengjinfan.cn */
layui.config({
    base: 'resources/js/'
}).use(['element', 'layer', 'navbar', 'tab'], function () {
    var $ = layui.jquery,
        navbar = layui.navbar(),
        tab = layui.tab({
            elem: '.admin-nav-card' //设置选项卡容器
        });
    //iframe自适应
    $(window).on('resize', function () {
        var $content = $('.admin-nav-card .layui-tab-content');
        $content.height($(this).height() - 147);
        $content.find('iframe').each(function () {
            $(this).height($content.height());
        });
    }).resize();

    //设置navbar
    navbar.set({
        spreadOne: true,
        elem: '#admin-navbar-side',
        cached: true,
        data: navs
        /*cached:true,
        url: 'datas/nav.json'*/
    });
    //渲染navbar
    navbar.render();
    //监听点击事件
    navbar.on('click(side)', function (data) {
        tab.tabAdd(data.field);
    });
});
var navs = []
console.log(Manager);
if (Manager) {
    navs = [{
        "title": "系统管理",
        "icon": "fa-cogs",
        "spread": false,
        "children": [{
            "title": "用户管理",
            "icon": "fa-table",
            "href": "/user/index"
        }, {
            "title": "商品管理",
            "icon": "fa-navicon",
            "href": "/product/index"
        }, {
            "title": "商品分类",
            "icon": "fa-navicon",
            "href": "/category/index"
        }]
    }]
} else {
    navs = [{
        "title": "商店管理",
        "icon": "fa-cubes",
        "spread": true,
        "children": [{
            "title": "我的商店",
            "icon": "&#xe641;",
            "href": "/shop/index"
        }]
    }, {
        "title": "仓库管理",
        "icon": "fa-cogs",
        "spread": false,
        "children": [{
            "title": "我的仓库",
            "icon": "fa-table",
            "href": "/store/index"

        }]
    }]
}